package com.xianggu.threadPool.demo;

import com.xianggu.threadPool.MyThreadPool;
import com.xianggu.threadPool.rejectStrategy.DefalutRejectHandle;
import com.xianggu.threadPool.rejectStrategy.DiscardRejectHandle;
import com.xianggu.threadPool.rejectStrategy.RejectHandle;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @author chengjy
 * @date 2025/3/14
 */
public class ThreadPoolDemo {
    public static void main(String[] args) {
        MyThreadPool myThreadPool = new MyThreadPool(2,4, 1000, TimeUnit.MILLISECONDS
                , new ArrayBlockingQueue<>(5), new DefalutRejectHandle());

        for (int i = 0; i < 8; i++) {
            myThreadPool.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + " is running");
                }
            });
        }
    }
}
